package com.hust.chatvedio;

import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;

import androidx.fragment.app.Fragment;
import android.os.Bundle;

import com.hust.chatvedio.fragment.*;
import com.hust.chatvedio.utils.Utils;
import com.yinglan.alphatabs.AlphaTabsIndicator;
import com.yinglan.alphatabs.OnTabChangedListner;

public class MenuActivity extends AppCompatActivity implements OnTabChangedListner {

    public static AlphaTabsIndicator mAlphaIndicator;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_menu);
        Utils.setStatusColor(this, false, true, R.color.colorPrimaryDarkMain2);
        initView();
        initData();
    }

    private void initView() {
        mAlphaIndicator = (AlphaTabsIndicator) findViewById(R.id.alphaIndicator);
//        mAlphaIndicator.getTabView(0).showNumber();
//        mAlphaIndicator.getTabView(1).showNumber(999);
//        mAlphaIndicator.getTabView(2).showNumber(999);
        mAlphaIndicator.getTabView(3).showPoint();
        mAlphaIndicator.setOnTabChangedListner(this);   //设置底部tab点击监听
        //mAlphaTabView.removeShow();      //移除当前角标
        // mAlphaTabsIndicator.setViewPager(ViewPager mViewPger);                     //设置ViewPager
        //mAlphaTabsIndicator.removeAllBadge();                                      //移除所有tab的角标
        //mAlphaTabsIndicator.setTabCurrenItem(int tabIndex);                        //设置tab选项
    }

    private void initData() {
        replaceFragement(new ChatFragment());
    }


    @Override
    public void onTabSelected(int tabNum) {
        switch (tabNum) {
            case 0:
                replaceFragement(new ChatFragment());
                break;
            case 1:
                replaceFragement(new ContactFragment());
                break;
            case 2:
                replaceFragement(new VedioFragment());
                break;
            case 3:
                replaceFragement(new PersonFragment());
                break;
            default:
                break;
        }

    }


    public void replaceFragement(Fragment fragment) {
        FragmentManager fragmentManager = getSupportFragmentManager();
        FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
        fragmentTransaction.replace(R.id.frame, fragment);
        fragmentTransaction.commit();
    }


    @Override
    public void onBackPressed() {
        super.onBackPressed();
        finish();
    }
}